package br.com.extrajudicial.models;

import org.springframework.beans.factory.annotation.Autowired;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.SessionScoped;

@Component
@SessionScoped
public class UserSession {
	
	@Autowired private Cart cart;
	
	private User currentUser;
	
	public void login(User user) {
		this.currentUser = user;
	}
	
	public boolean isLogged() {
		return this.currentUser != null;
	}

	public User getCurrentUser() {
		return currentUser;
	}

	public void logout() {
		this.currentUser = null;
		this.cart.clearCart();
	}
	
}
